# 函数的综合练习
money = 0
def select():
    """
    返回余额
    """
    return money
def witdhDraw(gMoney):
    """
    :param gMoney: 取款金额
    :return: 1、取款成功 0：余额不足 -1：输入错误
    """
    global money
    if gMoney <= 0:
        return -1
    if money >= gMoney:
        money -= gMoney
        return 1
    else:
        return 0
def deposit(dMoney):
    """
    :param dMoney: 存款金额
    :return: 成功返回余额，失败返回None
    """
    global money
    if dMoney > 0:
        money += dMoney
        return money
def main():
    print("1、查询余额")
    print("2、存款")
    print("3、取款")
    print("4、退出（任意键退出）")
    return int(input("请输入你的选择："))

name = input("请输入你的名字：")
print("----------主菜单----------")
print(f"{name},欢迎来到黑马银行ATM,请选择操作")
while True:
    chooise = main()
    if chooise == 1:
        print("----------查询余额----------")
        print(f"{name}，你好，你的余额剩余：{select()}")
    if chooise == 2:
        youMoney = int(input("输入存款金额："))
        b = deposit(youMoney)
        print("----------存款----------")
        if b:
            print(f"存款成功，当前余额：{money}")
        else:
            print(f"存款失败，检查是否输入错误")
    if chooise == 3:
        youMoney = int(input("输入取款金额："))
        b = witdhDraw(youMoney)
        print("----------取款----------")
        if b == 1:
            print(f"取款成功，当前余额：{money}")
        if b == 0:
            print(f"取款失败，余额不足，当前余额：{money}")
        if b == -1:
            print(f"取款失败，检查是否输入错误")
    if chooise == 4:
        break